import {
    GET_USERINFO,
    RECORD_USERINFO,
    SET_TOKEN
} from './mutation-types'



export default {


    [RECORD_USERINFO] (state, info){
        state.isLogin = true;
        state.userInfo = info;
    },
    // 获取用户信息
    [GET_USERINFO] (state, info) {
        if (state.userInfo && (state.userInfo.username !== info.username)) {
            return
        }
        if (!state.login) {
            return
        }
        if (!info.message) {
            state.userInfo = {...info}
        } else {
            state.userInfo = null
        }
    },
    [SET_TOKEN] (state, info){
        state.token = info;
    }

}
